/**
 * @(#)RpgTest.java	0.1 Nov 04, 2007
 *
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.wideskill.rpg4ejb3.sample.entity.rpg.impl;

import javax.persistence.Transient;

import com.wideskill.rpg4ejb3.sample.entity.rpg.IRpgTest;
import com.wideskill.rpg4ejb3.sample.entity.rpg.type.Services;
import com.wideskill.rpg4ejb3.sample.entity.rpg.type.IType;
import com.wideskill.rpg4ejb3.type.annotation.AS400Column;
import com.wideskill.rpg4ejb3.type.annotation.AS400Column.Fill;
import com.wideskill.rpg4ejb3.type.annotation.AS400Column.Usage;
import com.wideskill.rpg4ejb3.type.annotation.EntityAS400RPG;

/**
 * @author: Luigi Scarpato <luigi.scarpato at Widekill.Com>
 *
 */
@EntityAS400RPG(name="rpgtest",
	            fieldOrder={"identify",
							"service",
							"uniquekey",
							"errorcode"}
)
public class RpgTest<S extends Enum<Services> & IType> implements IRpgTest{

	// input
	@AS400Column(name="identify", usage=Usage.INPUT)	
	private final String identify;
	
	@AS400Column(name="service", usage=Usage.INPUT)	
	private final String service;
	
	@AS400Column(name="uniquekey", usage=Usage.INPUT, normalize=Fill.LEFT_ZERO)	
	private String uniqueKey;
	
	// output
	@AS400Column(name="errorcode", usage=Usage.OUTPUT)
	private String errorcode;

	@AS400Column(name="response", usage=Usage.OUTPUT)
	private String response;
	
	public RpgTest(S service, String identify, String uniqueKey) {
		
		this.service = service.getID();

		this.identify = identify;
		this.uniqueKey = uniqueKey;
	}

	public String getUniqueKey() {
		return uniqueKey;
	}

	public void setUniqueKey(String uniqueKey) {
		this.uniqueKey = uniqueKey;
	}

	public final String getErrorCode() {
		return errorcode;
	}
	
	public void setErrorCode(String errorcode){
		this.errorcode=errorcode;
	}

	public String getIdentify() {
		return identify;
	}

	public String getServices() {
		return service;
	}
	
	public String getResponse() {
		return response;
	}

	@Transient
	public Boolean isExist() {
		return "".equals(errorcode);
	}
}
